//
//  UIViewController+CLQ.m
//  rxtd_xfd
//
//  Created by clq on 15/4/13.
//  Copyright (c) 2015年 clq. All rights reserved.
//

#import "UIViewController+CLQ.h"

@implementation UIViewController (CLQ)

-(NSString *)getMatchScreenImageFullName:(NSString *)imgName
{
    NSString  *suffix = @"";
    if ([UIViewController is_iPhone5]) {
        suffix = @"-568h";
    }
    return [NSString stringWithFormat:@"%@%@",imgName,suffix];
}

-(UIImage *)getMatchScreenImage:(NSString *)imgName
{
    return [UIImage imageNamed:[self getMatchScreenImageFullName:imgName]];
}


+(BOOL)is_iPhone5
{
    BOOL result = NO;
    
    if ([UIScreen instancesRespondToSelector:@selector(currentMode)]) {
        result = CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size);
    }
    
    return result;
}

-(void) gotoNextViewControllerByPush:(UIViewController*) nextVC
{
    nextVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:nextVC animated:YES];
}

- (void)gotoToViewController:(NSString*) vcName animated:(BOOL)animated
{
    NSArray *temArray = self.navigationController.viewControllers;
    
    BOOL bFind = NO;
    for(UIViewController *temVC in temArray)
    {
        if([vcName isEqualToString:NSStringFromClass([temVC class])])
        {
            bFind = YES;
            [self.navigationController popToViewController:temVC animated:animated];
        }
    }
    //找不到，统一跳转到当前栈首页
    if(!bFind)
    {
        [self.navigationController popToRootViewControllerAnimated:animated];
    }
}

@end
